/**
 * @desc 实时获取当前时间
 * @return{string}
 * */

const padDate = function (value) {
  return value < 10 ? '0' + value : value;
};
export const getDateTime2 = (d, type) => {
  const date = new Date(d),
    year = date.getFullYear(),
    month = padDate(date.getMonth() + 1),
    day = padDate(date.getDate()),
    hours = padDate(date.getHours()),
    minutes = padDate(date.getMinutes()),
    seconds = padDate(date.getSeconds());
  if (type === 'date') {
    return year + '-' + month + '-' + day;
  } else {
    return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
  }
};